﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Timers;
using System.Net;


namespace MiniTalk
{
    public static class Program
    {
        const string MUTEXLOCK = "LocalChatProcessLock";

        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            using (var m=new Mutex(true,MUTEXLOCK))
            {
                //检查进程是否已经启动，已经启动则显示报错信息退出程序。 
                if (!m.WaitOne(100,false))
                {
                    MessageBox.Show("本程序已经在运行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    Application.Exit();
                    return;
                }

                //IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName());
                //IPAddress localIp = ips[ips.Length - 1];
                //string[] strs = localIp.ToString().Split('.');
                //if (strs[0] != "192")
                //{
                //    MessageBox.Show("检测到网卡非C类私有IP地址,因此无法使用本程序", "启动失败", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //    return;
                //}

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Landing());
            }
        }
    }
}
